import Vue from 'vue'
import Router from 'vue-router'

// 布局
import Layout from '@/components/Layout/Index'

Vue.use(Router)

export const CONST_ROUTER = [
  {
    path: 'zongti-yulan',
    name: 'ZongtiYulan',
    component: () => import('@/views/ChaxunTongji/ZongtiYulan/index.vue'),
    meta: {
      title: '总体排放量预览',
      icon: 'menu-icon1'
    }
  },
  {
    path: 'tongbi-chaxun',
    name: 'TongbiChaxun',
    component: () => import('@/views/ChaxunTongji/TongbiChaxun/index.vue'),
    meta: {
      title: '同比查询',
      icon: 'menu-icon1'
    }
  },
  {
    path: 'qushi-duibi',
    name: 'QushiDuibi',
    component: () => import('@/views/ChaxunTongji/QushiDuibi/index.vue'),
    meta: {
      title: '趋势对比查询',
      icon: 'menu-icon1'
    }
  },
  {
    path: 'zongti-duibi',
    name: 'ZongtiDuibi',
    component: () => import('@/views/ChaxunTongji/ZongtiDuibi/index.vue'),
    meta: {
      title: '对比查询',
      icon: 'menu-icon1'
    }
  }

]

const router = new Router({
  mode: 'hash',
  routes: [
    {
      path: '/',
      name: 'WorkSpace',
      component: Layout,
      meta: {
        title: '总体排放量预览',
        icon: 'menu-icon1'
      },
      redirect: '/' + CONST_ROUTER[0].path,
      children: CONST_ROUTER
    }
  ]
})

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    // document.title = to.meta.title
  }
  next()
})
export default router
